package com.thb.pay.api.agent.vo.resp;

import com.thb.pay.core.bean.BaseSuperVO;
import lombok.Data;

import java.io.Serializable;

/**
 * @Description 代理商 账户信息
 * @Author lucky
 * @data 2019/7/21 22:16
 */
@Data
public class AgentAccountVo extends BaseSuperVO implements Serializable {
    /**
     * 代理商ID
     */
    private Long agentId;

    /**
     * 账户余额
     */
    private Long balance;

    /**
     * 不可用余额
     */
    private Long unBalance;

    /**
     * 保证金
     */
    private Long securityMoney;

    /**
     * 总收益
     */
    private Long totalIncome;

    /**
     * 总支出
     */
    private Long totalExpend;

    /**
     * 今日收益
     */
    private Long todayIncome;

    /**
     * 今日支出
     */
    private Long todayExpend;

    /**
     * 可结算金额
     */
    private Long settAmount;

    /**
     * 账户状态,1-可用,0-停止使用
     */
    private Integer status;

    /**
     * 获取可用余额
     *
     * @return
     */
    public Long getAvailableBalance() {
        return this.balance - this.unBalance;
    }

    /**
     * 获取实际可结算金额
     *
     * @return
     */
    public Long getAvailableSettAmount() {
        Long subSettAmount = this.settAmount - this.unBalance;
        if (getAvailableBalance().compareTo(subSettAmount) == -1) {
            return getAvailableBalance();
        }
        return subSettAmount;
    }

    /**
     * 验证可用余额是否足够
     *
     * @param amount
     * @return
     */
    public boolean availableBalanceIsEnough(Long amount) {
        return this.getAvailableBalance().longValue() >= amount;
    }
}
